<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<script type="text/javascript">
    function run(generatorFunction) {
        var generatorItr = generatorFunction(resume);
        function resume(callbackValue) {
            generatorItr.next(callbackValue);
        }
        generatorItr.next()
    }
    run(function* myDelayedMessages(resume) {
        console.log(yield delay(1000, resume));
        console.log(yield delay(1200, resume));
    });

    function delay(time, callback) {
        setTimeout(function () {
            callback("Slept for "+time);
        }, time);
    }

</script>
</body>
</html>